package models

import (
	"order_srv/basic/config"
	"time"
)

// 黑名单
type Blacklist struct {
	Id        uint32    `gorm:"column:id;type:int UNSIGNED;comment:主键;primaryKey;not null;" json:"id"`                                     // 主键
	UserId    uint64    `gorm:"column:user_id;type:bigint UNSIGNED;comment:用户Id;not null;default:0;" json:"user_id"`                       // 用户Id
	BlackType uint64    `gorm:"column:black_type;type:bigint UNSIGNED;comment:黑名单类型  1永久黑名单 2临时黑名单;not null;default:2;" json:"black_type"` // 黑名单类型  1永久黑名单 2临时黑名单
	CreatedAt time.Time `gorm:"column:created_at;type:datetime;not null;default:CURRENT_TIMESTAMP;" json:"created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at;type:datetime;not null;default:CURRENT_TIMESTAMP;" json:"updated_at"`
	DeletedAt time.Time `gorm:"column:deleted_at;type:datetime;default:NULL;" json:"deleted_at"`
}

// TableName 表名
func (b *Blacklist) TableName() string {
	return "blacklist"
}

// 获取黑名单
func (b *Blacklist) GetBlackList() error {
	return config.DB.Where("user_id = ?", b.UserId).Limit(1).Find(&b).Error
}
